<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录</title>
    <link rel="stylesheet" href="denglu.css">
    <!-- <script type="text/javascript" src="denglu.js"></script> -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta2/css/all.min.css">
        <script>

            function nameCheck(){
            let reg = /^[\u4e00-\u9fa5]{3,4}$/;
            let name =document.getElementById("text").value;
            if (!reg.test(name) || name=='') {
            return false;
            }else{
            return true;
            }
        }

        function pwdCheck() {
        let reg = /^[\s\S]{6,12}/;
        let pwd = document.getElementById("password").value;
        if(!reg.test(pwd) || pwd==''){
            return false;
        }else{
            return true;
        }
    }
   /*function yonghu(id,password){
        this.id=id;
        this.password=password;
    };*/
    // var yonghu1=new yonghu('李乐宁','123456');
    // var yonghu2=new yonghu('杨邦杰','123456');
    // var yonghu3=new yonghu('吴海涛','123456');
    // var yonghu4=new yonghu('潘灵哲','123456');
    // var yonghu5=new yonghu('赵哲涛','123456');
    
    // var arr7=[yonghu1,yonghu2,yonghu3,yonghu4,yonghu5];
    // localStorage.setItem("arr7",JSON.stringify(arr7));
var a=window.localStorage.getItem('arr7');
    var b=JSON.parse(a);
    var c=b[0].id;
    var d=b[0].password;
    
function test(){
    if(nameCheck() && pwdCheck()){
        let name =document.getElementById("text").value;
        let pwd = document.getElementById("password").value;
       
        /*localStorage.setItem("arr7",JSON.stringify(arr7));*/
        /*var pwd2=a[0].password;
        var arr=JSON.parse(pwd2);*/  
            if(c== name){
                if(d== pwd){
                    alert('欢迎登陆！');
                    window.location.href="yonghu_wz.html"
                }
                else{
                    alert('密码错误！');
                }
            }
            else {
                alert('账号未注册');
            }
        }
        
       

    
    else{
        alert('用户名或密码格式错误！');
        location.reload();
    }
}

    </script>
</head>
<body>
    <div class="cotainer">
        <h2>王者登录</h2>
        <div class="input-box">
            <input type="text" id="text" placeholder="账号">
        </div>
        <div class="input-box">
            <!-- <i class="fas fa-eye-slash show_hide"></i> -->
            <input type="password" id="password" placeholder="密码">
        </div>
        <div class="indicator">
            <div class="icon-text">
                <i class="fas fa-exclamation-circle error_icon"></i>
                <h6 class="text">只能输入数字，字母，下划线</h6>
            </div>
        </div>
        
            <button class="ipt" onclick="test()"><strong>登录</strong></button>
       
        <div class="ch-box">
            <input type="checkbox"><p>我已同意用户协议</p>
        </div>

        <div class="help">
            <div class="hp"><a href="zhuce_wz.html"><p>注册</p></a></div>
            <div class="hp2"><a href="#"><p>帮助</p></a></div>
        </div>
    </div>

    <script>
        nameCheck();
        pwdCheck();

    </script>
</body>
</html>